﻿
Namespace LightSwitchApplication

    Public Class SubsidiaryLedgerByDepartment

        Private Sub SubsidiaryLedgerByDepartment_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
            ' Write your code here.
            MainAssetsTablep_departmentCode = Nothing
        End Sub

        Private Sub SubsidiaryLedgerByDepartment_Created()
            ' Write your code here.
            Dim comboControl As IContentItemProxy = Me.FindControl("MainAssetsTablep_departmentCode")
            comboControl.SetBinding(System.Windows.Controls.ComboBox.ItemsSourceProperty, "Screen.DepartmentsAll", System.Windows.Data.BindingMode.OneWay)
            comboControl.SetBinding(System.Windows.Controls.ComboBox.SelectedItemProperty, "Screen.MainAssetsTablep_departmentCode", System.Windows.Data.BindingMode.TwoWay)
        End Sub

        Private Sub AllDepartment_Execute()
            ' Write your code here.
            MainAssetsTablep_departmentCode = Nothing
        End Sub

        Private Sub AssetsByDeptCode_Loaded(succeeded As Boolean)
            Me.SumAccumulatedDepreciation = Me.AssetsByDeptCode.Sum(Function(x) x.AccumulatedDepreciaton)
            Me.SumTotalCost = Me.AssetsByDeptCode.Sum(Function(x) If(x.AssetAmount > 0, x.AssetAmount, x.BaseCost + x.VAT))
            Me.NetBookValue = Me.SumTotalCost - Me.SumAccumulatedDepreciation
        End Sub
    End Class

End Namespace
